
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<base href="<%=basePath%>">
<title>总部</title>
<link rel="stylesheet"
	href="${pageContext.request.contextPath}/css/bootstrap.min.css">
<link rel="stylesheet"
	href="${pageContext.request.contextPath}/css/main.css">
<script src="${pageContext.request.contextPath}/js/jquery.min.js"></script>
<script src="${pageContext.request.contextPath}/js/bootstrap.min.js"></script>
<script src="${pageContext.request.contextPath}/js/main.js"></script>
<script src="${pageContext.request.contextPath}/js/MD5.js"></script>
<script src="${pageContext.request.contextPath}/js/city2.js"></script>
<script type="text/javascript"
	src="${pageContext.request.contextPath}/js/citySelect2.js"></script>

</head>
<body>
	<%@ include file="header.jsp"%>
	<%@ include file="left.jsp"%>
	<style>
.main_div {
	min-width: 1000px;
	min-height: 60px
}

.force-overflow1-1 {
	border: none
}

.buttonPic>span {
	color: #FFFFFF;
	font-size: 36px
}

.countyVipCount {
	font-size: 18px;
	line-height: 50px
}

.countyVipCount span {
	color: red
}

.pageChange {
	float: right;
	color: #337ab7;
}

.pageChange>span {
	cursor: pointer
}

.pageChange>span:hover {
	color: blue
}
</style>
	<div id="index"
		style="position: absolute;left: 180px;top: 80px;bottom: 0;right: 0;">
		<section id="main2">
			<div class="scrollbar1-1" id="style1-1">
				<div class="main_div">
					<div class="main_title">
						<span>代理商恢复</span>
					</div>
					<form class="form-horizontal" style="margin-top: 60px">
						<div class="form-group" id="city_4">
							<label class="col-xs-3 control-label" style="text-align: right">
							省市区： <span id="city"></span>
							</label>
						</div>
						<div class="form-group">
							<label class="col-xs-2 control-label" style="text-align: right">UUID：</label>
							<div class="col-xs-3">
								<input type="text" id="UUID" class="form-control"
									placeholder="请输入UUID">
									<input type="text" id="id" style="display: none">
							</div>
						</div>
						<div class="form-group">
							<label class="col-xs-2 control-label" style="text-align: right">账号：</label>
							<div class="col-xs-3">
								<input type="text" id="name" class="form-control"
									placeholder="请输入用户名">
							</div>
						</div>
						<div class="form-group">
							<label class="col-xs-2 control-label" style="text-align: right">密码：</label>
							<div class="col-xs-3">
								<input type="password"  id="userPassword1" class="form-control"
									placeholder="请输入密码">
							</div>
						</div>
						<div class="form-group">
							<label class="col-xs-2 control-label" style="text-align: right">密码：</label>
							<div class="col-xs-3">
								<input type="password"  id="userPassword" class="form-control"
									placeholder="请再次输入密码">
							</div>
						</div>
						<div class="form-group">
							<label class="col-xs-2 control-label" style="text-align: right">姓名：</label>
							<div class="col-xs-3">
								<input type="text" id="userName" class="form-control"
									placeholder="请输入代理商姓名">
							</div>
						</div>
						<div class="form-group">
							<label class="col-xs-2 control-label" style="text-align: right">电话：</label>
							<div class="col-xs-3">
								<input type="text" id="userPhone" class="form-control"
									placeholder="请输入代理商电话">
							</div>
						</div>

						<script>
							var selectVal = new CitySelect({
								data : data,
								provId : "#prov4",
								cityId : '#city4',
								areaId : '#area4'
							});
						</script>
						<div class="form-group">
							<div class="col-xs-4 col-xs-offset-2">
								<button type="button" class="col-xs-6 btn btn-primary"
									onclick="submitPassword()">恢复</button>
							</div>
						</div>
					</form>
				</div>
			</div>
		</section>
		
	</div>
	<script>
	$(function(){
	    var URL = document.location.toString();
			var agentId = URL.split("=")[1];
			$("#id").val(agentId);
			$.post(urls + "agentAction/getAgentInfoById",
					{
						agentId : agentId,
					},
					function(data) {
                      $("#city").text(data.agentName);
					})
	    })
	    
	    
		function submitPassword() {
			var card = /^[a-z0-9A-Z_-]{6,20}$/;
			var phones=/^0?(13[0-9]|15[012356789]|17[013678]|18[0-9]|14[57])[0-9]{8}$/;			
			var userPassword = $("#userPassword").val();
			if( $("#userPassword").val()!=$("#userPassword1").val()){
			 alert("两次密码输出不一致");
			 return;
			}
			if(!phones.test($("#userPhone").val())){
			alert("请输入正确的手机号");
			 return;
			}
			if(($("#area4").find("option:selected").val()==-1)||(!$("#name").val())||(!$("#userName").val())){
			alert("请填写完整信息");
			 return;
			}
			if (!card.test(userPassword)) {
				alert("请输入6到20位由数字、字母、下划线、减号组成的密码")
	
			} else {
				$.post(urls + "agentAction/updateAgentInfo",
					{
					    id:$("#id").val(),
						agentName : $("#city").text(),
						agentRegion : $("#area4").find("option:selected").val(),
						phone : $("#userPhone").val(),
						password : $.md5(userPassword),
						principal : $("#userName").val(),
						account : $("#name").val(),
						UUID:$("#UUID").val()
					},
					function(data) {
						if (data==250) {
							alert("账号或代理商已存在");							
						}if (data==251) {
							alert("该代理商没有绑定微信账号");							
						} else if (data==false){
							alert("添加代理商失败")
						}else if (data==true){
							alert("恢复代理商成功")
						}
					})
			}
		}
		

	
	</script>
</body>
</html>